﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.Module;

namespace LPV_POS.mh_pos.mh_cauhinh
{
    public partial class mh_cauhinhbaocao : DevExpress.XtraEditors.XtraForm
    {
        xl_filetext filetext;
        string[] key;
        string[] display;
        private void f_cauhinhbaocao(string tencongty, string diachi, string masothue, string chuky1, string chuky2, string chuky3, string chuky4, string chuky5,
                                                     string tencongty_true, string diachi_true, string masothue_true, string chuky1_true, string chuky2_true, string chuky3_true, string chuky4_true, string chuky5_true)
        {
            filetext = new xl_filetext();
            //byte ketqua = 0;
            key = new string[] { "[00001]", "[00002]", "[00003]", "[00004]", "[00005]", "[00006]", "[00007]", "[00008]",
                                            "[00009]", "[00010]", "[00011]", "[00012]", "[00013]", "[00014]", "[00015]", "[00016]"};
            display = new string[] { tencongty,  diachi,  masothue,  chuky1,  chuky2,  chuky3,  chuky4, chuky5,
                                                tencongty_true, diachi_true, masothue_true, chuky1_true, chuky2_true, chuky3_true, chuky4_true, chuky5_true};
            filetext.f_writedataintext("cauhinhbaocao.txt", Application.StartupPath + "\\baocao", key, display);
        }
        public mh_cauhinhbaocao()
        {
            InitializeComponent();
        }

        private void bton_luu_Click(object sender, EventArgs e)
        {
                string tencongty;
                string tencongty_true;
                string diachi;
                string diachi_true;
                string masothue;
                string masothue_true;
                string chuky1;
                string chuky1_true;
                string chuky2;
                string chuky2_true;
                string chuky3;
                string chuky3_true;
                string chuky4;
                string chuky4_true; 
                string chuky5;
                string chuky5_true;
                
                if(txt_tencongty.Text != "")
                  tencongty = txt_tencongty.Text;
                else
                    tencongty = "";

                if (check_tencongty.Checked == true)
                    tencongty_true = "true";
                else
                    tencongty_true = "false";

                    if (txt_diachi.Text != "")
                        diachi = txt_diachi.Text;
                    else
                        diachi = "";

                    if (check_diachi.Checked == true)
                        diachi_true = "true";
                    else
                        diachi_true = "false";

            if(txt_masothue.Text != "")
                masothue  = txt_masothue.Text;
            else
                masothue = "";

            if (check_masothue.Checked == true)
                masothue_true = "true";
            else
                masothue_true = "false";

            if(txt_chuky1.Text != "")
                 chuky1 = txt_chuky1.Text;
            else
                chuky1 ="";

            if (check_chuky1.Checked == true)
                chuky1_true = "true";
            else
               chuky1_true = "false";

            if(txt_chuky2.Text != "")
                chuky2 = txt_chuky2.Text;
            else
                chuky2 = "";

            if (check_chuky2.Checked == true)
                chuky2_true = "true";
            else
                chuky2_true = "false";

            if(txt_chuky3.Text != "")
                chuky3 = txt_chuky3.Text;
            else
                chuky3 = "";

            if (check_chuky3.Checked == true)
                chuky3_true = "true";
            else
                chuky3_true = "false";

            if(txt_chuky4.Text != "")
                chuky4 = txt_chuky4.Text;
            else
                chuky4 = "";

            if (check_chuky4.Checked == true)
                chuky4_true = "true";
            else
                chuky4_true = "false";

            if(txt_chuky5.Text != "")
                chuky5 = txt_chuky5.Text;
            else
                chuky5 = "";

            if (check_chuky5.Checked == true)
                chuky5_true = "true";
            else
                chuky5_true = "false";
                f_cauhinhbaocao(tencongty, diachi, masothue, chuky1, chuky2, chuky3, chuky4, chuky5,
                                            tencongty_true, diachi_true, masothue_true, chuky1_true, chuky2_true, chuky3_true, chuky4_true, chuky5_true);
                this.Close();
        }

        private void mh_cauhinhbaocao_Load(object sender, EventArgs e)
        {
            xl_filetext filetext = new xl_filetext();
            filetext.f_readfiletext(Application.StartupPath + "\\baocao\\cauhinhbaocao.txt");
            txt_tencongty.Text = Variable.str_tencongty;
            txt_diachi.Text = Variable.str_diachicongty;
            txt_masothue.Text = Variable.str_masothuecongty;
            txt_chuky1.Text = Variable.str_chuky1;
            txt_chuky2.Text = Variable.str_chuky2;
            txt_chuky3.Text = Variable.str_chuky3;
            txt_chuky4.Text = Variable.str_chuky4;
            txt_chuky1.Text = Variable.str_chuky1;
            txt_chuky5.Text = Variable.str_chuky5;
            if (  Variable.str_tencongty_true.Trim() == "true")                
                check_tencongty.Checked = true;
            else
                check_tencongty.Checked = false;

            if (Variable.str_masothuecongty_true.Trim() == "true")
                check_masothue.Checked = true;
            else
                check_masothue.Checked = false;

            if (Variable.str_diachicongty_true.Trim() == "true")
                check_diachi.Checked = true;
            else
                check_diachi.Checked = false;

            if (Variable.str_chuky1_true.Trim() == "true")
                check_chuky1.Checked = true;
            else
                check_chuky1.Checked = false;

            if (Variable.str_chuky2_true.Trim() == "true")
                check_chuky2.Checked = true;
            else
                check_chuky2.Checked = false;

            if (Variable.str_chuky3_true.Trim() == "true")
                check_chuky3.Checked = true;
            else
                check_chuky3.Checked = false;

            if (Variable.str_chuky4_true.Trim() == "true")
                check_chuky4.Checked = true;
            else
                check_chuky4.Checked = false;

            if (Variable.str_chuky5_true.Trim() == "true")
                check_chuky5.Checked = true;
            else
                check_chuky5.Checked = false;
        }

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            Mod_messagebox mess = new Mod_messagebox();
            mess.messagebox_pos("Thông báo", "Bạn muốn thoát?", loaithongbao.yesno.GetHashCode());
            if (Variable.thongbao == true)
            {

                this.Close();
            }
        }

        private void bton_tencongty_Click(object sender, EventArgs e)
        {
            txt_tencongty.Text = new cpublic().loadformchu_point(230, 200);
        }

        private void bton_diachi_Click(object sender, EventArgs e)
        {
            txt_diachi.Text = new cpublic().loadformchu_point(230, 200);
        }

        private void bton_masothue_Click(object sender, EventArgs e)
        {
            txt_masothue.Text = new cpublic().loadformchu_point(230, 200);
        }

        private void bton_chuky1_Click(object sender, EventArgs e)
        {
            txt_chuky1.Text = new cpublic().loadformchu_point(230, 200);
        }

        private void bton_chuky2_Click(object sender, EventArgs e)
        {
            txt_chuky2.Text = new cpublic().loadformchu_point(230, 200);
        }

        private void bton_chuky3_Click(object sender, EventArgs e)
        {
            txt_chuky3.Text = new cpublic().loadformchu_point(250, 200);
        }

        private void bton_chuky4_Click(object sender, EventArgs e)
        {
            txt_chuky4.Text = new cpublic().loadformchu_point(250, 200);
        }

        private void bton_chuky5_Click(object sender, EventArgs e)
        {
            txt_chuky5.Text = new cpublic().loadformchu_point(250, 200);
        }
    }
}